/**
 * Created by forcht on 2018/7/14.
 */
public class Solution {
    public int removeDuplicates(int[] A) {
        int index = 1;
        for (int i = 1; i < A.length; i++) {
            if (A[i] != A[i - 1]) {
                A[index] = A[i];
                index++;
            }
        }
        return index;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] a = {1, 2};
        System.out.println(solution.removeDuplicates(a));
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + ",");
        }
    }
}
